<!DOCTYPE html>
<html lang="zh">

	<head>
		<meta charset="UTF-8" />
		<meta name="viewport" content="width=device-width, initial-scale=1.0" />
		<meta http-equiv="X-UA-Compatible" content="ie=edge" />
		<title>递归和循环</title>
	</head>

	<body>
		<p>在控制台输入dog，表示循环生成</p>
		<p>在控制台输入cat，表示递归生成</p>
		<script type="text/javascript">
			function loop() {
				var obj = {};
				var max = 100;
				var i = 0;
				for(; i <= max; i += 1) {
					obj['prop' + i] = i;
				}
				return obj;
			}

			function recursion() {
				var obj = {};
				//				var max = 20982;
				var max = 100;

				function inner(obj, i) {
					if(i > max) {
						return obj;
					}
					obj['prop' + i] = i;
					return inner(obj, i + 1);
				}
				return inner(obj, 0);
			}
			var dog = loop();
			console.log('dog', dog);

			//			var cat = recursion();
			//			console.log('cat', cat);
		</script>
	</body>

</html>